---@class Stack : LuaObject
local this = BaseClass('Stack')

function this:__ctor()
    self:Clear()
end

-- 末尾插入
function this:PushBack(value)
    self.last = self.last + 1
    self.stack[self.last] = value
end

-- 取出并移除
function this:Pop()
    local value = self:GetPop()
    self:Remove()
    return value
end

-- 取出
function this:GetPop()
    return self.stack[self.last]
end

function this:Remove()
    table.remove(self.stack, self.last)
    self.last = self.last - 1
end

-- 长度
function this:Count()
    return self.last + 1
end

function this:Clear()
    self.stack = {}
    self.last = -1
end

Stack = this